package com.aios.action.user.group;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import com.aios.action.AbstractManagementAction;
import com.aios.entity.UserGroup;
import com.aios.exception.ItemNotFoundException;
import com.aios.exception.NullReferenceAccessException;
import com.aios.service.UserGroupService;

public abstract class AbstractUserGroupAction extends AbstractManagementAction {

	private static final long serialVersionUID = 1L;

	@Qualifier("userGroupService")
	@Autowired protected UserGroupService userGroupService;
	
	protected UserGroup userGroup;

	public UserGroup findById() {
		if(id != null) {
			try{
				return userGroupService.findById(id);
			}catch(Exception e) {
				throw new ItemNotFoundException("Id : " + id);
			}
		} else {
			//logger
			throw new NullReferenceAccessException("Id cannot be null");
		}
	}

	public UserGroup getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}
	
}
